<template>
  <div class="courier">
    <ComHeader title="物流查询" leftArrow='true' />
    <div class="courier-input flex-display flex-center-pack">
      <input type="text" class="flex-num-one" v-model="queryValue" placeholder="请输入物流单号">
      <span @click="queryLog">查询</span>
    </div>
    <div class="result-box" v-if="logisticsList && logisticsList.length>0">
      <div class="result-success">
        <div id="resultTop" class="result-top">
          <span class="col1-up">时间</span>
          <span class="col2">地点和跟踪进度</span>
          <div role-slot="m_result_redpacket" class="red-packet"></div>
        </div>
        <ul class="result-list">
          <li :class="{'last': !index}" v-for="(item,index) in logisticsList" :key="index">
            <div class="col1">
              <dl>
                <dt>{{item.time}}</dt>
                <dd></dd>
              </dl>
            </div>
            <div class="col2">
              <span style="z-index: 0"></span>
            </div>
            <div class="col3">{{item.status}}</div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import { Toast, Indicator } from "mint-ui";
import api from "@/fetch/api";
import ComHeader from '@/common/ComHeader'
export default {
  data() {
    return {
      queryValue: "", // 物流单号
      logisticsList: [] // 快递数据
    };
  },
  created() {
    this.queryValue = this.$route.query.code;

    if(this.getUrlParams('type') == 'xiadan'){
      this.queryValue = this.getUrlParams('kd_order_no')
      console.log(789)
      this.queryLog('xiadan')
    }
  },
  methods: {
    queryLog( type) {
      if (this.queryValue) {
        Indicator.open({
          text: "查询中...",
          spinnerType: "fading-circle"
        });
        api.getexpressinfo({
            userid: this.$route.query.userid,
            type : type,
            kd_order_no: this.getUrlParams('kd_order_no'),
            order_code: this.getUrlParams('order_code'),
          })
          .then(err => {
            Indicator.close()  
            console.log(err);
          })
          .catch(res => {
            Indicator.close()  
            console.log(res);
            if(res.status === 200) {
                console.log(typeof res.data)
               
                if(typeof res.data == 'object') {
                    Toast({
                        message:res.data.msg ,
                        duration: 2000,
                    });
                    return
                }
                let data = res.data ? JSON.parse(res.data) :''
                if(data.result.list && data.result.list.length > 0) {
                    this.logisticsList = data.result.list
                }
            }
          });
          
      }else {
        Toast({
          message: "请填写物流单号",
          duration: 2000
        });
      }
    }
  },

  components: {
    Toast,
    Indicator,
    ComHeader
  }
};
</script>

<style lang="scss" scoped>
.sureBtn {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  border-bottom: 1px solid #e5e5e5;
  span {
    width: 30%;
    height: 30px;
    line-height: 30px;
    text-align: center;
    display: inline-block;
    background: #0087ff;
    color: #fff;
    margin: 0 30px;
    border-radius: 3px;
  }
  span:first-child {
    background: #ccc;
  }
}
.result-box {
  margin-top: 20px;
}
.show-log {
  width: 90%;
  height: 45px;
  line-height: 45px;
  margin: 0 auto;
  box-sizing: border-box;
  text-align: center;
  color: #fff;
  border-radius: 5px;
  background: #0087ff;
}
.tipTile {
  width: 100%;
  height: 50px;
  line-height: 50px;
  text-align: center;
  color: red;
}
.log-search {
  width: 100%;
  padding: 5px 0.6rem 5px 0.2rem;
  height: 40px;
  line-height: 40px;
  background: #fff;
  box-sizing: border-box;
  position: relative;
  i {
    position: absolute;
    left: 0.3rem;
  }
  input {
    outline: none;
    border-radius: 5px;
    width: 100%;
    height: 100%;
    padding-left: 0.6rem;
    border: 1px solid #e5e5e5;
  }
}
.log-title {
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background: #fff;
  position: relative;
  border-bottom: 1px solid #e5e5e5;
  > img {
    position: absolute;
    width: 20px;
    height: 20px;
    position: absolute;
    right: 5px;
    top: 8px;
  }
}
.mint-indexlist {
  background: #fff;
  box-sizing: border-box;
}

.log-item {
  background: #fff;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border-bottom: 1px solid #e5e5e5;
}
.log-file {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  padding: 20px 20px 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
}
.not-result {
  position: relative;
  > span {
    margin-top: 5px;
  }
  > span:last-child {
    color: #1973bf;
  }
}

.area-class {
  width: 100%;
  height: 50%;
}
.courier {
  width: 100%;
  height: 100%;
  .courier-name {
    width: 100%;
    height: 50px;
    font-size: 0.5rem;
    text-align: center;
    line-height: 50px;
  }
  .courier-input {
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    height: 45px;
    margin-top: 67px;
    > input {
      background: #fff;
      border: none;
      padding-left: 10px;
      outline: none;
    }
    > span {
      color: #fff;
      border: 1px solid rgba(255, 137, 156, 1);
      background: rgba(255, 137, 156, 1);
      display: inline-block;
      line-height: 45px;
      padding: 0 10px;
    }
  }
  .courier-reader {
    width: 100%;
    height: 45px;
    background: #fff;
    width: 90%;
    margin: 20px auto;
    line-height: 45px;
    padding-left: 10px;
    overflow: hidden;
    border: 1px solid #ccc;
    span {
      color: #3781e4;
    }
  }
  .result-success {
    background: #fff;
  }

  .result-top {
    border-top: 1px solid #e6e6e6;
    border-bottom: 0;
    height: 43px;
    line-height: 43px;
    font-size: 16px;
    color: #5a5a5a;
    .col1-up {
      background: url(…9sjKKZfhJvyHYR1CVaGUBD0L1GqosYkQxETV+DroQECDAAHTBNKtk1K9cAAAAASUVORK5CYII=)
        60px 14px no-repeat;
      cursor: pointer;
      width: 3.25rem;
      padding-left: 25px;
      display: inline-block;
      margin-right: 50px;
    }
  }

  .result-list {
    border-top: 1px solid #e6e6e6;
  }

  .result-list li {
    display: -webkit-box;
    -webkit-box-align: center;
    overflow: hidden;
    color: #828282;
    border-bottom: 1px solid #e6e6e6;
  }

  .result-list.sortup .col2 span:before {
    border: 0;
    border-right: 1px solid;
    border-top: 1px solid;
    margin-top: 2px;
  }
  .result-list li.last {
    color: rgba(255, 161, 176, 1);
  }
  .result-list li .col1 {
    padding: 0.3rem;
    text-align: center;
    font-size: 0.35rem;
    font-weight: bold;
    font-family: Helvetica, Arial, sans-serif;
  }
  ul,
  dl {
    list-style: none;
  }

  .result-list li .col1 dd {
    margin-top: 0.25rem;
  }
  .result-list li .col2 {
    width: 1.25rem;
    position: relative;
  }
  .result-list .col2 span {
    border: 1px solid #e6e6e6;
    border-radius: 50%;
    position: absolute;
    left: 0;
    top: 50%;
    margin-top: -0.5rem;
    width: 0.5rem;
    height: 0.5rem;
    background: #fff;
    z-index: 2;
    color: #e6e6e6;
  }
  .result-list .last .col2 span {
    border-color: rgba(255, 137, 156, 1);
    color: rgba(255, 161, 176, 1);
  }
  .result-list.sortup .col2 span:before {
    border: 0;
    border-right: 1px solid;
    border-top: 1px solid;
    margin-top: 10px;
  }
  .result-list .col2 span:before {
    position: absolute;
    top: 50%;
    left: 50%;
    content: "";
    width: 6px;
    height: 6px;
    border-left: 1px solid;
    border-bottom: 1px solid;
    -webkit-transform: translate(-50%, -50%) rotate(135deg);
    transform: translate(-50%, -50%) rotate(135deg);
  }

  .result-list li .col3 {
    -webkit-box-flex: 1;
    padding: 0.2rem;
    font-size: 0.35rem;
    line-height: 0.5rem;
    position: relative;
  }
  .result-list li:first-child .col3:before {
    top: 50%;
  }
  .result-list .col3:before {
    content: "";
    position: absolute;
    top: -1rem;
    bottom: -1rem;
    left: -38px;
    border-left: 1px solid #e6e6e6;
  }

  .courier-result {
    width: 90%;
    height: auto;
    padding: 0 20px;
    box-sizing: border-box;
    background: #fff;
    margin: 20px auto 0;
  }
  .courier-result__item {
    width: 100%;
    height: 1rem;
    border-bottom: 1px solid #e5e5e5;
    > span {
      display: block;
    }
    > img {
      width: 0.5rem;
      height: 0.5rem;
    }
  }
  .courier-result__item:last-child {
    border: none;
  }
}
</style>

